@extends('admin.master')
        
        @section('content')
        
            <h1>Relatos</h1>
            
            {{-- will be used to show any messages --}}
            @if (Session::has('message'))
            <div class="alert alert-info">{{ Session::get('message') }}</div>
            @endif
            
            <div class="table-responsive">
                <table id="sort" class="table table-hover table-bordered table-condensed">
                    <thead>
                        <tr>
                            <th>T&iacute;tulo</th>
                            <th>Bajada</th>
                            <th class="text-center">Estado</th>
                            <th>Categor&iacute;a</th>
                            <th class="text-center">Ver</th>
                            <th class="text-center">Editar</th>
                            <th class="text-center">Borrar</th>
                        </tr>
                    </thead>
                    <tbody>
                        @foreach($relatos as $key => $value)
                        <tr id="items_{{ $value->id }}">
                            <td>{{{ $value->titulo }}}</td>
                            <td>
                                {{ Str::limit($value->bajada, $limit = 30, $end = '...') }}
                            </td>
                            <td class="text-center">
                                @if($value->estado)
                                <span class="glyphicon glyphicon-ok"></span>
                                @else
                                <span class="glyphicon glyphicon-minus"></span>
                                @endif
                            </td>
                            <td>
                                {{ $value->tags->first()->nombre }}
                            </td>

                            <!-- we will also add show, edit, and delete buttons -->
                            <td class="text-center">
                                <!-- show the relato (uses the show method found at GET admin/relatos/{id} -->
                                <a class="btn btn-xs btn-success" target="_blank" href="{{ URL::to('admin/relatos/' . $value->id) }}"><span class="glyphicon glyphicon-search"></span></a>
                            </td>
                            <td class="text-center">
                                <!-- edit this relato (uses the edit method found at GET /relatos/{id}/edit -->
                                <a class="btn btn-xs btn-info" href="{{ URL::to('admin/relatos/' . $value->id . '/edit') }}"><span class="glyphicon glyphicon-pencil"></span></a>
                            </td>
                            <td class="text-center">
                                {{-- delete the relato (uses the destroy method DESTROY admin/relatos/{id} --}}
                                {{-- The DELETE HTTP verb is used when accessing the nerds.destroy route. 
                                Since you can’t just create a button or form with the method DELETE, 
                                we will have to spoof it by creating a hidden input field in our delete form. --}}

                                {{ Form::open(array('url' => 'admin/relatos/' . $value->id)) }}
                                {{ Form::hidden('_method', 'DELETE') }}
                                {{ Form::button('<span class="ladda-label"><span class="glyphicon glyphicon-trash"></span></span>', ['type' => 'submit', 'class' => 'ladda-button delete-button btn btn-xs btn-danger', 'data-style'=>'zoom-in']) }}
                                {{ Form::close() }}
                            </td>

                        </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
        @stop
            
@section('js-footer')
@parent
{{ HTML::script('assets/admin/js/scripts.js') }}
<script type="text/javascript">
    $( ordenarItems("#sort tbody", "{{ URL::route('adminOrderRelatos') }}", 'y') );
</script>
@stop